# def add(a, b):
#     return a + b
# print(add(1, 2)) # 输出3

# def fib(n):
#     if n <= 1:
#         return n
#     else:
#         return fib(n-1) + fib(n-2)
#
# print(fib(8)) # 输出21

# x=10
# y=20
# def func():
#     y=30
#     global x
#     x=40
#     print(f'内部x={x},y={y}') # 40 30
# func()
# print(f'外部x={x},y={y}') # 40 20

#案例：ATM
name='Rasion'
money=10000
def deposit():#存款
    global money
    print(f'欢迎{name}存款，当前余额{money}元')
    money+=int(input('请输入存款金额：'))
    print(f'存款成功，当前余额{money}元')

def withdraw():#取款
    global money
    print(f'欢迎{name}取款，当前余额{money}元')
    money-=int(input('请输入取款金额：'))
    print(f'取款成功，当前余额{money}元')

def check_balance():#查询余额
    print(f'欢迎{name}查询余额，当前余额{money}元')
def menu():#主菜单
    print(f'----主菜单----\n{name},欢迎使用ATM机！\n1.存款\n2.取款\n3.查询余额\n4.退出')
    choice=input('请输入您的选择：')
    return choice

while True:
    choice=menu()
    if choice=='1':
        deposit()
    elif choice=='2':
        withdraw()
    elif choice=='3':
        check_balance()
    elif choice=='4':
        exit()